import type { Middleware } from '../context/types';

export const numberValidationMiddleware: Middleware = (key, value, next) => {
  if (key.includes('count') || key.includes('number')) {
    if (typeof value !== 'number') {
      console.warn(`Expected number for key ${key}, got ${typeof value}`);
      next(0);
      return;
    }
  }
  next(value);
};

export const stringValidationMiddleware: Middleware = (key, value, next) => {
  if (key.includes('text') || key.includes('name') || key.includes('title')) {
    if (typeof value !== 'string') {
      console.warn(`Expected string for key ${key}, got ${typeof value}`);
      next('');
      return;
    }
  }
  next(value);
};
